package com.cust.cow.controller;

import com.cust.cow.common.CattleAddress;
import com.cust.cow.common.Result;
import com.cust.cow.pojo.cattle;
import com.cust.cow.service.CattleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin("*")
@RequestMapping("/cattle")
public class CattleController {
    @Autowired
    CattleService cattleService;


    /**
     * 添加牛
     */
    @PostMapping("insertCattle")
    public Result insertCattle(@RequestBody cattle cattle)
    {
        return cattleService.insertCattle(cattle);
    }

    /**
     * 查看所有牛
     */
    @RequestMapping("findCattleAll")
    public List<cattle> findCattleAll()
    {
        return cattleService.findCattleAll();
    }

    @RequestMapping("findCattleById")
    public cattle findCattleById(@RequestParam("cattleId") Integer cattleId)
    {
        return cattleService.findCattleById(cattleId);
    }

    /**
     * 删除牛
     */
    @RequestMapping("deleteCattle")
    public Result deleteCattle(@RequestParam("cattleId") Integer cattleId)
    {
        return cattleService.deleteCattle(cattleId);
    }

    @RequestMapping("findCattleAddress")
    public List<CattleAddress> findCattleAddress()
    {
        return cattleService.findCattleAddress();
    }


    @RequestMapping("findCattleAddressById")
    public CattleAddress findCattleAddressById(Integer cattleId)
    {
        return cattleService.findCattleAddressById(cattleId);
    }

    //修改牛舍信息

}
